﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DataAccessLogic;
using System.Data;

namespace BusinessLogic
{
    [Serializable]
    public class State : FormattedCodeTable<State>
    {
        #region Methods
        public State() { }        

        public override void Create()
        {
            this._id = StateDataAccess.Create(this);
        }

        public override void Delete()
        {
            StateDataAccess.Delete(this);
        }

        protected override List<State> ProtectedGetAll()
        {
            DataTable dt = StateDataAccess.GetAll();

            List<State> states = null;

            if((dt != null) && (0 < dt.Rows.Count))
            {
                states = new List<State>();

                foreach (DataRow row in dt.Rows)
                {
                    states.Add(StateDataAccess.BindDataToState(row));
                }
            }

            return states;
        }

        protected override State ProtectedGetByID(Guid id)
        {            
            return StateDataAccess.GetByID(id);             
        }        

        public override void Update()
        {
            throw new NotImplementedException();
        }
        #endregion
        
        #region Properties
        public override string CacheKeyName
        {
            get
            {
                return SEPDefaults.CacheKeyNames.STATES;
            }
        }
        #endregion
    }
}